home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / commasm.zip / COMM-ASM.MSG next >
Text File  |  1988-07-13  |  25KB  |  718 lines

  1. Article 5187 of comp.sys.ibm.pc:
  2. Path: cgh!vu-vlsi!cbmvax!rutgers!ames!ucbcad!ucbvax!hoptoad!pozar
  3. From: pozar@hoptoad.uucp (Tim Pozar)
  4. Newsgroups: comp.lang.c,comp.sys.ibm.pc
  5. Subject: Re: C code for opening a communications file
  6. Message-ID: <3731@hoptoad.uucp>
  7. Date: 25 Dec 87 16:39:42 GMT
  8. References: <621@umbc3.UMD.EDU>
  9. Reply-To: pozar@hoptoad.UUCP (Tim Pozar)
  10. Organization: Syncstream/Widget Systems (San Francisco)
  11. Lines: 704
  12. Xref: cgh comp.lang.c:2667 comp.sys.ibm.pc:5187
  13.  
  14. In article <621@umbc3.UMD.EDU> dipto@umbc3.umd.edu (Dipto Chakravarty) writes:
  15. >
  16. >Expertise needed to open a communications file (COM1) on an IBM PC !!!!!!
  17. >
  18. >My fellow C-pals, I need your help to get  an equivalent of the following
  19. >BASICA code. This code in BASICA works fine as an experiment. However, in
  20. >real  life, I am required to  implement the following in Microsoft C 4.0,
  21. >for a communications program.
  22. >
  23. >100 OPEN "COM1:9600, N, 8, 1, RS, CS, DS, CD" AS #1
  24. >
  25. >Above given is the line which opens COM1. The IBM BASIC manual will have
  26. >the detailed descriptions of the options used. For my friends who aren't
  27. >in touch with the finer details of BASIC syntax here is a short summary
  28. >of the options used in the above statement.
  29. >
  30. >OPEN   opens an asynchronous communications file
  31. >COM1   communications port 1
  32. >9600   speed; specifying the transmit/receive bit rate in bits/sec (bps)
  33. >N      specifies that there is no Xmit parity; no receive parity checks
  34. >8      specifies the number of transmit/receive data bits
  35. >1      specifies the number of stop bits
  36. >RS     suppreses RTS (Request To Send)
  37. >CS     this option allows user to ignore this line
  38. >DS     this option allows user to ignore this line
  39. >CD     this option allows user to ignore the Carrier Detect checks
  40. >
  41.  
  42.   Ok, folks here it is.  I've been holding off on posting this
  43. for more than a year for fear of riticule for the sloppy code.
  44. This is an asm source communications functions to be linked in
  45. with MSC 3.0 to 5.0.  This is only here to see how asm is linked
  46. in with MSC and to see how interupt handlers work.  If anyone is
  47. planning to seriously get into communications routines, I would
  48. suggest the FOSSIL drivers, NOT this code.  Also look carfully
  49. at the code before using it.  This is an old version and I think
  50. the resettty() is not fully functional...
  51.  
  52.  
  53. ---
  54.  
  55. /*
  56.  * Comport.h
  57.  *
  58.  * defines the bit masking for the get_mcr()
  59.  *
  60.  * Copyright (C) Tim M. Pozar 1987
  61.  *
  62.  */
  63.  
  64. /*
  65.  * get_msr()
  66.  *   Function to read (get) the byte located in the Modem Status
  67.  * Register (3FEh).  The table below describes the byte returned.
  68.  *   bit  description
  69.  *    0   Delta Clear to Send (DCTS)
  70.  *        Indicates that the !CTS input to the chip has changed state
  71.  *        since the last time it was read by the processor.
  72.  *    1   Delta Data Set Ready (DDSR)
  73.  *        Indicates that the !DRS input to the chip has changed since
  74.  *        last time it was read by the processor.
  75.  *    2   Trailing Edge Ring Indicator (TERI)
  76.  *        Indicates that the !RI input to the chip has changed from
  77.  *        an on (logical 1) to an off (logical 0) condition.
  78.  *    3   Delta Rx Line Signal detect (DRLSD)
  79.  *        Indicates that the !RLSD input to the chip has changed state.
  80.  * NOTE: Whenever bit 0, 1, 2, or 3 is set to a logical 1, a modem status
  81.  *       interrupt is generated.
  82.  *
  83.  *    4   Clear to Send (CTS)
  84.  *        This bit is the complement of the clear to send (!CTS) input.
  85.  *        If bit 4 (LOOP) of the MCR is set to a logical 1, this is
  86.  *        equivalent to RTS in the MCR.
  87.  *    5   Data Set Ready (DSR)
  88.  *        This bit is the complement of the data set ready (!DSR) input.
  89.  *        If bit 4 (LOOP) of the MCR is set to a logical 1, this is
  90.  *        equivalent to DTR in the MCR.
  91.  *    6   Ring Indicator (RI)
  92.  *        This bit is the complement of the ring indicator (!RI) input.
  93.  *        If bit 4 (LOOP) of the MCR is set to a logical 1, this is
  94.  *        equivalent to OUT 1 in the MCR.
  95.  *    7   Receive Line Signal Detect (RLSD) or Carrier Detect (CD).
  96.  *        This bit is the complement of the received line signal detect
  97.  *        (!RLSD) input. If bit 4 (LOOP) of the MCR is set to a logical 1,
  98.  *        this is equivalent to OUT 2 in the MCR.
  99.  */
  100.  
  101. #define  DCTS       1
  102. #define  DDSR       2
  103. #define  TERI       4
  104. #define  DRLSD      8
  105. #define  CTS       16
  106. #define  DST       32
  107. #define  RI        64
  108. #define  RLSD     128   /* Also know as ... */
  109. #define  CD       128
  110. ---
  111.                   ... and the asm code...
  112. ---
  113.  
  114. title IBM PC Communications I/O Routines
  115. ;
  116. ; Orginal code -- Curt Klinsing
  117. ;
  118. ; Changes and updates -- Copyright (c) 1987 Tim Pozar
  119. ;
  120. ; ver: 0
  121. ; rev: 2
  122. ; March 13th 1987
  123. ; This code is in a very early stage and should not be let out.
  124. ; Several other extensive functions are planned as well as changes
  125. ; to the current code.
  126. ;
  127. ; 2/20/87
  128. ;   Changed segment declarations and function names (eg. _function)
  129. ; to fit Microsoft C 4.0 and linker requirements.
  130. ;
  131. ; FUNCTIONS CHANGED/ADDED --
  132. ; set_tty(port_number)
  133. ;   Function to find current settings of the port and set up serial
  134. ; port for 'baud' and 'lcbyte', and enable DTR.  This will set up the
  135. ; port number base addressed passed to it (eg. 3F8h) and all functions
  136. ; will use this port until the function is used again. (NOT READY FOR USE)
  137. ;
  138. ; reset_tty()
  139. ;   Function to put the port back into the state it was when it was
  140. ; first found by set_tty().  If set_tty() was not called it will not
  141. ; change the settings of the port. (NOT READY FOR USE)
  142. ;
  143. ; 3/13/87
  144. ; get_msr()
  145. ;   Function to read (get) the byte located in the Modem Status
  146. ; Register (3FEh).  The table below describes the byte returned.
  147. ;   bit  description
  148. ;    0   Delta Clear to Send (DCTS)
  149. ;        Indicates that the !CTS input to the chip has changed state
  150. ;        since the last time it was read by the processor.
  151. ;    1   Delta Data Set Ready (DDSR)
  152. ;        Indicates that the !DRS input to the chip has changed since
  153. ;        last time it was read by the processor.
  154. ;    2   Trailing Edge Ring Indicator (TERI)
  155. ;        Indicates that the !RI input to the chip has changed from
  156. ;        an on (logical 1) to an off (logical 0) condition.
  157. ;    3   Delta Rx Line Signal detect (DRLSD)
  158. ;        Indicates that the !RLSD input to the chip has changed state.
  159. ; NOTE: Whenever bit 0, 1, 2, or 3 is set to a logical 1, a modem status
  160. ;       interrupt is generated.
  161. ;
  162. ;    4   Clear to Send (CTS)
  163. ;        This bit is the complement of the clear to send (!CTS) input.
  164. ;        If bit 4 (LOOP) of the MCR is set to a logical 1, this is
  165. ;        equivalent to RTS in the MCR.
  166. ;    5   Data Set Ready (DSR)
  167. ;        This bit is the complement of the data set ready (!DSR) input.
  168. ;        If bit 4 (LOOP) of the MCR is set to a logical 1, this is
  169. ;        equivalent to DTR in the MCR.
  170. ;    6   Ring Indicator (RI)
  171. ;        This bit is the complement of the ring indicator (!RI) input.
  172. ;        If bit 4 (LOOP) of the MCR is set to a logical 1, this is
  173. ;        equivalent to OUT 1 in the MCR.
  174. ;    7   Receive Line Signal Detect (RLSD).
  175. ;        This bit is the complement of the received line signal detect
  176. ;        (!RLSD) input. If bit 4 (LOOP) of the MCR is set to a logical 1,
  177. ;        this is equivalent to OUT 2 in the MCR.
  178. ;
  179. ;   Currently this driver is set up for COM1 (3f8h).
  180. ;   If you are using the interupt driven buffer, take out the code
  181. ; that enables the DTR so that it doesn't get raised until the vectors
  182. ; are initilized.
  183. ;
  184.  
  185. _TEXT   SEGMENT BYTE PUBLIC 'CODE'
  186. _TEXT   ENDS
  187. _DATA   SEGMENT BYTE PUBLIC 'DATA'
  188. _DATA   ENDS
  189. CONST   SEGMENT BYTE PUBLIC 'CONST'
  190. CONST   ENDS
  191. _BBS    SEGMENT BYTE PUBLIC 'BBS'
  192. _BBS    ENDS
  193.  
  194. DGROUP  GROUP   CONST, _BBS, _DATA
  195.       ASSUME    CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
  196.  
  197. _TEXT      SEGMENT
  198. ;
  199. ;A set of Lattice C and MSC callable functions to support
  200. ;interrupt driven character I/O on the  IBM PC. Input
  201. ;is buffered, output is polled.
  202. ;
  203. ;added functions (TMP) --
  204. public  _set_tty        ;find current